package LeetCode.Sort;
/*
稳定不排序 (2,2,1)
 */
public class InsertionSort {
    public static void Sort(Comparable[] arr){
        int len = arr.length;
        for (int i = 1; i < len; i++) {
            for (int j = i; j > 0; j--) {
                if(arr[j].compareTo(arr[j-1]) > 0){
                    int temp = (int) arr[j];
                    arr[j] = arr[j-1];
                    arr[j-1] = temp;
                }
                else{
                    break;
                }
            }
        }
    }
}
